import { SEP } from "../helpers/constents";

/**
 * 创建一个action
 *
 * @param {function} dispatch redux的dispatch
 * @param {object} config
 * @param {string} config.type action的type
 * @param {*} config.payload action的payload
 * @param {boolean} config.isFlow 是否是一个flow
 */
export default function createAction(dispatch, config) {
  const { type, namespace, isFlow } = config;

  return payload =>
    dispatch({
      type: `${namespace}${SEP}${type}`,
      payload,
      isFlow
    });
}
